<div class="boxed">
   <div class="boxTop">
     <div class="boxTopLeft">
       <div class="boxTopRight">
         <div class="boxName"><img src="http://v0.ttimg.vn/images/icons/icon_video02.jpg" alt="video" /><span>Quản trị video (Dành cho Admin và Mod)</span></div>
       </div>
     </div>
   </div>
   <div class="boxBody admbox">
    <center>
        
        <div style="width: 100%; text-align: left; margin-top: 10px">
            <div style="text-align: center; font-weight: bold; font-size: 120%">Admin Page</div>
            <div>
            <form action="/event/admin" method="post" id="admin_form">
                <fieldset>
                    <legend style="font-weight: bold">Tìm kiếm</legend>
                    <div>
                        <table width="100%" border="0" cellpadding="2px" cellspacing="0">
                            <tr>
                                <td>Từ khóa</td>
                                <td>Chuyên mục</td>
                                <td>Công bố</td>
                                <td>Nổi bật</td>
                            </tr>
                            <tr>
                                <td><input type="text" name="keyword" style="width: 200px" value="<?echo $this->search['keyword']?>"></td>
                                <td>
                                    <select name="category">
                                        <option value="0">Tất cả</option>
                                        <?php
                                        if(is_array($this->tree_term) && count($this->tree_term)>0)
                                        foreach ($this->tree_term as $tree_term){
                                            if(is_array($tree_term) && count($tree_term) > 0)
                                                foreach($tree_term as $cat){
                                                    if ($this->search["category"]==$cat->tid)
                                                        echo '<option value="' . $cat->tid . '" selected="selected">' .  str_repeat("- ", $cat->depth*2) . $cat->name . '</option>';
                                                    else
                                                        echo '<option value="' . $cat->tid . '">' .  str_repeat("- ", $cat->depth*2) . $cat->name . '</option>';
                                                }
                                        }
                                        ?>
                                    </select>
                                </td>
                                <td>
                                    <select name="status">
                                        <option value="0" <?echo ($this->search['status']=="0") ? 'selected="selected"' : ""?>>Tất cả</option>
                                        <option value="1" <?echo ($this->search['status']=="1") ? 'selected="selected"' : ""?>>Chưa công bố</option>
                                        <option value="2" <?echo ($this->search['status']=="2") ? 'selected="selected"' : ""?>>Đã công bố</option>
                                    </select>
                                </td>
                                <td>
                                    <select name="status">
                                        <option value="0" <?echo ($this->search['status']=="0") ? 'selected="selected"' : ""?>>Tất cả</option>
                                        <option value="1" <?echo ($this->search['status']=="1") ? 'selected="selected"' : ""?>>Chưa công bố</option>
                                        <option value="2" <?echo ($this->search['status']=="2") ? 'selected="selected"' : ""?>>Đã công bố</option>
                                    </select>
                                </td>
                            </tr>
                        </table>
                        <div style="margin-top: 5px;">
                            <input type="submit" class="detail-button" value="Tìm" style="float: none;">
                        </div>
                    </div>
                </fieldset>
            </form>
            </div>
            <form action="/event/admin" method="post" id="admin_form">
            <div style="margin-top: 10px">
                <table width="100%" border="1" cellpadding="2px" cellspacing="0" style="border-collapse: collapse; border-color: #999999">
                    <tr style="bacground-color: #F3F2FD">
                        <td style="font-weight: bold; width: 30px; text-align: center"><input type="checkbox" id="check_all"></td>
                        <td style="font-weight: bold; text-align: center">Tiêu đề</td>
                        <td style="font-weight: bold; text-align: center">Logo</td>
                        <td style="font-weight: bold; text-align: center">Cộng đồng</td>
                        <td style="font-weight: bold; text-align: center">Danh mục</td>
                        <!--<td style="font-weight: bold; text-align: center">Down</td>-->
                        <td style="font-weight: bold; text-align: center">Sáng lập</td>
                        <td style="font-weight: bold; text-align: center">Nổi bật</td>
                        <td style="font-weight: bold; text-align: center">Công bố</td>
                    </tr>
                    <?
                    for ($i=0; $i<count($this->events); $i++)
                    {
                        $event=$this->events[$i];
                        $epicture = EVENT_STATIC_SERVER."/images/nophoto.gif";
                       if($event->logo){
                           $epicture = EVENT_IMG_URL_PATH."/".$event->logo;
                       }
                       $href = "/event/detail/".$eventObj->eid;
                        echo '<tr>';
                        echo '<td style="text-align: center"><input type="checkbox" name="eids[]" class="selected_clip" value="' . $event->eid . '"></td>';
                        echo '<td>' . l($event->title, "play/" . $event->eid, array("target" => "_blank")) . '</td>';
                        echo '<td>' . $event->name . '</td>';
                        echo '<td style="text-align: center">' . date("d-m-Y", $event->created) . '</td>';
                        echo '<td style="text-align: center">' . $event->play_counter . '</td>';
                        //echo '<td style="text-align: center">' . $event->download_counter . '</td>';
                        echo '<td style="text-align: center">' . (($event->noibat==1) ? "Có" : "Không") . '</td>';
                        echo '<td style="text-align: center">' . (($event->status==1) ? "Có" : "Không") . '</td>';
                        echo '<td>' . $event->category_name . '</td>';
                        echo '<td>' . $event->channel_name . '</td>';
                        echo '<td style="text-align: center"><a href="' . url("video/admin/view/" . $event->eid) . '"><img src="/sites/video.tamtay.vn/themes/ttvideo3/images/b_edit.png" border="0" title="edit"></a></td>';
                        echo '</tr>';
                    ?>
                    <tr>
                        <td style="text-align: center"><input type="checkbox" name="eids[]" class="selected_clip" value="<?=$event->eid?>"></td>
                        <td><a href="<?php echo $href;?>"><?=$event->name?></a></td>
                        <td><img src="<?php echo $epicture;?>" onload="resizeImage(this,95,95)"/></td>
                        <td><?=$event->name?></td>
                    </tr>
                    <?php }?>
                </table>
                <div style="margin-top: 10px">
                    <fieldset>
                        <legend style="font-weight: bold">Với các video được chọn</legend>
                        <div>
                            <div style="float: left">
                                <span style="display: block">&nbsp;</span>
                                <select name="song_action" id="i_song_action">
                                    <option value="">Chọn thao tác</option>
                                    <option value="promoted">Nổi bật</option>
                                    <option value="unpromoted">Bỏ nổi bật</option>
                                    <option value="public">Công bố</option>
                                    <option value="unpublic">Bỏ công bố</option>
                                    <option value="category">Đổi chuyên mục</option>
                                    <option value="delete">Xóa bài hát</option>
                                </select>
                                <input type="button" style="float: none;" class="detail-button" id="change_category" value="Thực hiện">
                            </div>
                            <div style="float: left; margin-left: 10px">
                                <span style="display: block">Chọn một chuyên mục</span>
                                <select name="cid" class="<?php if(isset($errors['cid']) && $errors['cid']!="") echo "boderErr ";?>select w20pe">
                                    <?php 
                                    $totalCategory = count($this->categoryList);
                                    
                                    for($i=0;$i<$totalCategory;$i++){
                                        $categoryObj =  $this->categoryList[$i];
                                    ?>
                                    <option value="<?php echo $categoryObj->tid;?>" <?php if($categoryObj->tid== $event->cid)echo "selected=\"selected\"";?>><?php echo $categoryObj->name;?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div style="float: left">
                                <input name="commit" value="Ok" onclick="return checkSubmit();" type="submit">  
                            </div>
                            <div style="clear: both"></div>
                        </div>
                        <input type="hidden" name="command" id="command">
                        
                    </fieldset>
                </div>
                <div style="margin-top: 10px; text-align: center; font-weight: bold;">
                    <?
                    echo $this->pager;
                    ?>
                </div>
            </div>
            </form>
        </div>
        
        
    </center>
    <script language="javascript">
        $(document).ready(function(){
            $("#check_all").click(function(){
                var status=this.checked;
                $("input.selected_clip").each(function(){
                    this.checked=status;
                });
            });
        });
        
        function checkSubmit(){
            var haveCheck = false;
            $('.song_checkbox').each(function(){
                if($(this).attr('checked') == true)
                    haveCheck = true;
            });
            if(haveCheck == false){
                alert('Bạn cần chọn một sự kiện trước khi thực hiện');
                return false;
            }
            if($('#i_event_action').val() == ''){
                alert('Bạn cần chọn một thao tác để thực hiện');
                return false;
            }
            if(confirm('Bạn chắc muốn thực hiện?')){
                return true;
            }
            return false;
        }
    </script>
    </div>
</div>